package com.ruoyi.project.bid.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bid.domain.UserDownload;
import com.ruoyi.project.bid.service.IUserDownloadService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
//import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户下载记录Controller
 * 
 * @author ruoyi
 * @date 2023-11-27
 */
@RestController
@RequestMapping("/download")
public class UserDownloadController extends BaseController
{
    @Autowired
    private IUserDownloadService userDownloadService;

    /**
     * 查询用户下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('project:download:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserDownload userDownload)
    {
        startPage();
        List<UserDownload> list = userDownloadService.selectUserDownloadList(userDownload);
        return getDataTable(list);
    }

    /**
     * 导出用户下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('project:download:export')")
    @Log(title = "用户下载记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(UserDownload userDownload)
    {
//        List<UserDownload> list = userDownloadService.selectUserDownloadList(userDownload);
//        ExcelUtil<UserDownload> util = new ExcelUtil<UserDownload>(UserDownload.class);
//        return util.exportExcel(list, "download");
        return null;
    }

    /**
     * 获取用户下载记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:download:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userDownloadService.selectUserDownloadById(id));
    }

    /**
     * 新增用户下载记录
     */
    @PreAuthorize("@ss.hasPermi('project:download:add')")
    @Log(title = "用户下载记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserDownload userDownload)
    {
        return toAjax(userDownloadService.insertUserDownload(userDownload));
    }

    /**
     * 修改用户下载记录
     */
    @PreAuthorize("@ss.hasPermi('project:download:edit')")
    @Log(title = "用户下载记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserDownload userDownload)
    {
        return toAjax(userDownloadService.updateUserDownload(userDownload));
    }

    /**
     * 删除用户下载记录
     */
    @PreAuthorize("@ss.hasPermi('project:download:remove')")
    @Log(title = "用户下载记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userDownloadService.deleteUserDownloadByIds(ids));
    }
}
